#ifndef __SUPER_CAP_H__
#define __SUPER_CAP_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "main.h"
#ifdef USE_FREERTOS
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "can_task.h"
#else
#include "can.h"
#endif

#define SUPER_CAP_OK 0
#define SUPER_CAP_NULL_PTR 1
#define SUPER_CAP_OFFLINE 2
#define SUPER_CAP_MAILFULL 3

typedef struct 
{
#ifdef USE_FREERTOS
    QueueHandle_t can_queue;
#else
    CAN_HandleTypeDef* hcan;
#endif
    float bat_voltage;
    float bat_current;
    float bat_power;
    float cap_voltage;
    float cap_power;
    float chassis_current;
    float chassis_power;
    uint8_t status;
}super_cap_TypeDef;

#ifdef USE_FREERTOS
uint8_t super_cap_init(super_cap_TypeDef* hcap, QueueHandle_t can_queue);
#else
uint8_t super_cap_init(super_cap_TypeDef* hcap, CAN_HandleTypeDef* hcan);
#endif
uint8_t super_cap_cmd(super_cap_TypeDef* hcap, float limit_power, float target_power);
void super_cap_callback(super_cap_TypeDef* hcap, CAN_RxHeaderTypeDef* rx_header, uint8_t* data);

#ifdef __cplusplus
}
#endif

#endif